<script setup>
import { userGetFeedbackListApi } from '@/api/feedback';
import FeedbackList from '@/components/feedbackList.vue';
import { reactive, ref } from 'vue'

const feedbackList = reactive({
    feedbacks:[]
})
const showFeedbackList = reactive({
    feedbacks:[],
    pageInfo:{}
})
   //获取反馈列表
   getFeedbackList(0)
   async function getFeedbackList(page){
    try{
        const resp = await userGetFeedbackListApi(page)
        if(resp.data.code === 200){
            if(page === 0){
                showFeedbackList.feedbacks = []
            }
            feedbackList.feedbacks = resp.data.data.content 
            showFeedbackList.pageInfo = resp.data.data.page 
            if(feedbackList.feedbacks.length !== 0){
                feedbackList.feedbacks.forEach(feedback =>{
                    showFeedbackList.feedbacks.push(feedback)
                })
            }  
        } 
    }catch(e){
        console.log(e)
    }
   }
//获取下一页数据
const getMore = async (pageInfo)=>{
    if(pageInfo.totalPages === 1 || pageInfo.number+1 >= pageInfo.totalPages){
        return
    }else{
        getFeedbackList(pageInfo.number+1)
    } 
}
</script>
<template>
    <div class="feedback-box">
        <FeedbackList
        :feedbackList="showFeedbackList"
        :isFeedbacktUser="false"
        :showAudit="false"
        @queryList="getMore"
        >
        </FeedbackList>
    </div>
</template>

<style lang="scss" scoped>
.feedback-box{
    height: 80vh;
    overflow: scroll;
}
::-webkit-scrollbar{
    display: none;
    background-color: aliceblue;
}
</style>